package cn.fscode.sign.client.crypto;

import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;

import java.util.Base64;

/**
 * @author shenguangyang
 */
public class RsaAsymmetricCrypto extends BaseAsymmetricCrypto {

    public RsaAsymmetricCrypto() {

    }

    @Override
    public String encrypt(String data, KeyType keyType, String privateKey, String publicKey) {
        RSA rsa = new RSA(privateKey, publicKey);
        return Base64.getEncoder().encodeToString(rsa.encrypt(data, keyType));
    }

    @Override
    public AsymmetricCryptoType type() {
        return AsymmetricCryptoType.RSA;
    }
}
